package com.example.picofteacherend.controller;

import com.example.picofteacherend.dto.LoginDto;
import com.example.picofteacherend.dto.RegisterDto;
import com.example.picofteacherend.service.UserService;
import com.example.picofteacherend.utils.CodeMsg;
import com.example.picofteacherend.utils.Result;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author: zjb
 * @description:
 * @date: 2023/3/19 19:30
 * @version: 1.0
 */
@RestController
@RequestMapping("/")
public class UserController {

    @Autowired
    UserService userService;
    @PostMapping("login")
    public Result<String> login(@RequestBody LoginDto loginDto){
        String token = userService.login(loginDto.getNo(), loginDto.getPassword());
        return new Result<>(token);
    }

    @PostMapping("register")
    public Result register(@RequestBody RegisterDto registerDto){
        boolean register = userService.register(registerDto);
        return new Result<>(register);
    }

    @GetMapping("logout")
    public Result result(){
        return new Result<>(true);
    }
}
